package com.hosever.controller;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.hosever.core.AbstractController;
import com.hosever.model.PageView;
import com.hosever.model.User;
import com.hosever.service.PageViewService;

@Controller
@RequestMapping("/home")
public class PubController extends
		AbstractController<PageView, PageViewService> {
	
	/**
	 * 浏览量统计
	 * @param menuItem
	 * @param thisUrl
	 * @param ipAddr
	 * @param session
	 * @param ipAddrCHN
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/setPageView", method = RequestMethod.GET)
	public void setPageView(String menuItem
			,String thisUrl
			,String ipAddr
			,HttpSession session
			,String ipAddrCHN
			,Model model){
		User loginUser = (User) session.getAttribute("loginUser");
		PageView pageView = new PageView();
		pageView.setViewMenu(menuItem);
		if(loginUser==null){
			pageView.setCreateUser("guest");
		}else{
			pageView.setCreateUser(loginUser.getId());
		}
		pageView.setViewUrl(thisUrl);
		pageView.setIpAddr(ipAddr);
		pageView.setIpAddrChinese(ipAddrCHN);
		service.save(pageView);
	}
}









